package thinking

object 伴生对象 {
  def main(args: Array[String]): Unit = {

    val bob = Dog("bob")
    println(bob.name)
  }

  class Dog private() {
    var name: String = _
  }

  object Dog {
    def apply(name: String): Dog = {
      val dog = new Dog()
      dog.name = name
      dog
    }
  }

}
